package com.milkshopbackend.milkshop.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.milkshopbackend.milkshop.Service.ProductSearchService;
import com.milkshopbackend.milkshop.common.Result;
import com.milkshopbackend.milkshop.entity.ProductDTO;
import com.milkshopbackend.milkshop.entity.ProductSearchDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/products/search")
@RequiredArgsConstructor
public class ProductSearchController {
    private final ProductSearchService productSearchService;

    @GetMapping
    public Result<IPage<ProductDTO>> search(ProductSearchDTO searchDTO) {
        return Result.success(productSearchService.search(searchDTO));
    }
}